﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;

using Bussiness_Objects;

namespace DataObjects.ADO
{
    public class SqlLoaiDocGia : ILoaiDocGiaDao
    {
        public DataTable GetTable()
        {
            string sqlString = "sp_LOAIDOCGIA_selectAll";
            return Db.Read(sqlString, null);
        }        

        public string Insert(object businessData)
        {
            LoaiDocGia _sach = businessData as LoaiDocGia;

            if (_sach != null)
            {
                _sach.SetParameterInsert();
                string sqlString = "sp_LOAIDOCGIA_insert";
                return Db.ExecuteStoreProcedure(sqlString, _sach.parms);
            }
            return "Error";
        }

        public string Update(object businessData)
        {
            LoaiDocGia _sach = businessData as LoaiDocGia;

            if (_sach != null)
            {
                _sach.SetParameterUpdate();
                string sqlString = "sp_LOAIDOCGIA_update";
                return Db.ExecuteStoreProcedure(sqlString, _sach.parms);
            }
            return "Error";
        }

        public string Delete(object businessData)
        {
            LoaiDocGia _sach = businessData as LoaiDocGia;
            if (_sach != null)
            {
                _sach.SetParameterDelete();
                string sqlString = "sp_LOAIDOCGIA_delete";
                return Db.ExecuteStoreProcedure(sqlString, _sach.parms);
            }
            return "Error";
        }
    }
}
